<template>
	<view>
		<view class="" @click="chooseImage" style="width: 750upx; height: 600upx;text-align: center;">
			<image v-if="avatar!==''" style="width: 100%;height: 100%;" :src="avatar" mode=""></image>
			<image v-if="avatar===''" style="width: 200upx;height: 200upx;margin-top: 180upx;" src="../../../../static/xiangji.png" mode=""></image>
			<text v-if="avatar===''" style="color:#ccc;display: block;">点击添加封面</text>
		</view>
		<view class="" style="background-color: #fff;">
			<view class="" style="border-bottom: 3upx solid #ccc;padding: 0upx 30upx;height: 100upx;line-height: 100upx;">
				<input disabled @click="to_Top" style="height: 100upx;line-height: 100upx;" type="text" value="" placeholder="点击选择标题列表~" />
			</view>
			<view class="">
			<!-- <view contenteditable="true" style="padding: 0upx 30upx;width: 750upx;min-height: 500upx;line-height: 60upx;border: none;outline: 0;"> -->
				<!-- <input disabled type="text" value="" placeholder="添加文字,分享美丽心情" /> -->
				<textarea maxlength="2050" style="padding: 0upx 30upx;width: 750upx;min-height: 800upx;line-height: 60upx;" value="" placeholder="添加文字,分享美丽心情" />
			</view>
		</view>
		<button type="default" style="margin: 50upx 5%;background-color: #000000;color: #fff;">发布</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
					avatar:'',
					user_id:'',
					res:[],
			}
		},
		onLoad() {
			uni.getStorage({
			        key: 'user_id',
			        success: (res) => {
			         this.user_id = res.data
			         this.setAjax()
			        },
			       });
		},
		methods: {
			to_Top: function(){
				uni.navigateTo({
					url:'../Top/Top'
				})
			},
			chooseImage(){
				var _this = this
				uni.chooseImage({
				    count: 1, //默认9
				    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				    sourceType: ['album'], //从相册选择
				    success: function (res) {
							let file = res.tempFilePaths
							var images = []
							var img = ''
							// console.log(file)
							for(var i = 0; i<res.tempFilePaths.length; i++) {
								uni.uploadFile({
									url: 'https://cx.mingmeijt.com/Api/Upload/index',
									//仅为示例，非真实的接口地址
									filePath: file[i],
									name: 'file',
									formData: {
										'user': 'test'
									},
									success: (res) => {
										// console.log(res)
										images.push(JSON.parse(res.data).data)
										_this.imagess = images
										_this.avatar = 'https://cx.mingmeijt.com'+ _this.imagess[0]
										// console.log(_this.avatar)
										
										img = img + JSON.parse(res.data).url + ';'
										_this.imgurl = img
									}
								});
							}
				    }
				});
			},
		}
	}
</script>

<style>

</style>
